<?php

/**
 * @var $config
 * @var $key
 */


include("../WeSql/widget.php");
include("../WeSql/config.php");
include("../WeSql/WeSql.php");

//获取更新
@$package = $_REQUEST['package'];

@$weSql = new WeSql($config, $key);


if ($package == "") {
    $code = -1;
    $msg = "不能留空";
    $exception = "出现了参数为空的情况！";
} else {
    if (preg_match("/[a-zA-Z][.][0-9a-zA-Z]/",$package)){
        if($weSql->isSelectField("updates",[
            "package" => $package
        ])){
            $code = 1;
            $msg = $weSql->select("updates","package = '${package}'",2);
            $exception = "";
        }else{
            $code = -1;
            $msg = "没有该包名的数据";
            $exception = "数据库里找不到该包名的更新记录数据";
        }
    }else{
        $code = -1;
        $msg = "包名不合法";
        $exception = "包名没有按照正常包名传入！";
    }
}

@$result = [
    "code" => $code,
    "msg" => $msg,
    "exception" => $exception
];
echo json_encode($result, JSON_UNESCAPED_UNICODE);